#include "stdafx.h"

#include <list>
#include <algorithm>
#include <iostream>

#include <gtest/gtest.h>

TEST(TestAlgorithm, find)
{
	using namespace std;

	cout << green	<< "The operator== used to determine the match between an element and the specified value "
					<< "must impose an equivalence relation between its operands. " 
					<< white 
					<< std::endl;

   list <int> L;
   list <int>::iterator Iter;
   list <int>::iterator result;
   
   L.push_back( 40 );
   L.push_back( 20 );
   L.push_back( 10 );
   L.push_back( 30 );
   L.push_back( 10 );

   cout << "L = ( " ;
   for ( Iter = L.begin( ) ; Iter != L.end( ) ; Iter++ )
      cout << *Iter << " ";
   cout << ")" << endl;
   
   result = find( L.begin( ), L.end( ), 10 );
   if  ( result == L.end( ) )
      cout << "There is no 10 in list L.";
   else {
      cout << "There is a 10 in list L";
      if ( ++result != L.end() )
         cout << " and it is followed by a " << *result << ".";
   }
   cout << endl;

}